var ACTION = require("../../base/action");
var utils = require("../../utils/utils");
var time = require("../../utils/time");
var ocrGml = require("../../utils/ocrGml");

function getActionSleep(config, ad, contentType) {
  var actionSleep = new ACTION(contentType, config);
  actionSleep.goStart = function () {
    var ocrItem = ocrGml.captureExistOne("睡觉赚钱", true);
    if (ocrItem) {
      this.execFCount++;
      this.updateStorage();
      utils.clickOcrItem(ocrItem);
      sleep(utils.getRandom(2.5, 3, 1000));
    }
    return ocrItem;
  };
  actionSleep.beforeExec = function () {
    var content = "我要睡了";
    if (utils.clickTextStartsWith(content)) {
      this.execSCount++;
      this.updateStorage();
      sleep(utils.getRandom(2, 3, 1000));
      return true;
    }
    return false;
  };
  actionSleep.exec = function () {};
  actionSleep.afterExec = function () {
    console.log(this.name, time.str(), "afterExec");
    back();
    sleep(utils.getRandom(2, 3, 1000));
  };
  return actionSleep;
}

module.exports = getActionSleep;
